package com.example.myapplication.designmode.factory;
//  工厂
public class Factory {
    public static Product createProduct(String type) {
        if ("A".equals(type)) {
            return new ConcreteProductA() {
                @Override
                public String getUse() {
                    return "那你来管管我呀 " + type;
                }
            };
        } else if ("B".equals(type)) {
            return new ConcreteProductB() {
                @Override
                public String getUse() {
                    return "那你来管管我呀 " + type;
                }
            };
        } else {
            throw new IllegalArgumentException("Unsupported product type: " + type);
        }
    }
}
